<template>
  <div class="app-container">

    <!-- 工具按钮 -->
  

    <!-- 表格 -->
    <el-table :data="list" border stripe>

      <el-table-column
        label="#"
        width="50">
        <template slot-scope="scope">
          {{ (page - 1) * limit + scope.$index + 1 }}
        </template>
      </el-table-column>

      <el-table-column  prop="mobile"   label="电话号码" />
      <el-table-column  prop="nickname"    label="学生姓名" />
	     
      <el-table-column   prop="age"   label="年龄" />
  
	  
    <el-table-column label="操作" width="200" align="center">
		  
        <template slot-scope="scope">
         <router-link :to="'/member/get/'+scope.row.id">
            <el-button type="primary" size="mini" icon="el-icon-edit">已学习</el-button>
          </router-link>
          
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页组件 -->
    <el-pagination
      :current-page="page"
      :total="total"
      :page-size="limit"
      :page-sizes="[5, 10, 20, 30, 40, 50, 100]"
      style="padding: 30px 0; text-align: center;"
      layout="total, sizes, prev, pager, next, jumper"
      @size-change="changePageSize"
      @current-change="changeCurrentPage"
    />
  </div>
</template>

<script>
import memberApi from '@/api/member'

export default {
  // 定义数据模型
  data() {
    return {
      list: [], // 列表
      total: 0, // 总记录数
      page: 1, // 页码
      limit: 10 // 每页记录数
    }
  },

  // 页面渲染成功后获取数据
  created() {
    this.fetchData()
  },

  // 定义方法
  methods: {
    fetchData() {
      // 调用api
      memberApi.pageList(this.page, this.limit).then(response => {
        this.list = response.data.rows;
        this.total = response.data.total;
			console.log(this.list+"AA");
      })
    },

    // 每页记录数改变，size：回调参数，表示当前选中的“每页条数”
    changePageSize(size) {
      this.limit = size
      this.fetchData()
    },

    // 改变页码，page：回调参数，表示当前选中的“页码”
    changeCurrentPage(page) {
      this.page = page
      this.fetchData()
    },


  }
}
</script>